Skip to content

Conversation

@cfi2017
Copy link

@cfi2017 cfi2017 commented Jul 18, 2025

This PR implements #984

This change introduces two annotations:

  • load-balancer.hetzner.cloud/protocol-ports allows specifying a mapping of ports to their respective protocol
  • load-balancer.hetzner.cloud/http-certificates-ports allows specifying a mapping of ports to one or more certificates

This PR is in a draft state as the certificates part currently returns a 422 from the Hetzner API. I have an open ticket with the loadbalancer team about this. I can replicate this behaviour through the UI.

@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

❌ Patch coverage is 89.81481% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.25%. Comparing base (7e69452) to head (1079c75).
⚠️ Report is 55 commits behind head on main.

Files with missing lines Patch % Lines
internal/hcops/load_balancer.go 74.28% 6 Missing and 3 partials ⚠️
internal/annotation/name.go 97.26% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #985      +/-   ##
==========================================
- Coverage   71.27%   68.25%   -3.02%     
==========================================
  Files          22       22              
  Lines        3046     3141      +95     
==========================================
- Hits         2171     2144      -27     
- Misses        706      831     +125     
+ Partials      169      166       -3     
Flag Coverage Δ
e2e ?
unit 68.25% <89.81%> (+0.79%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lukasmetzner
Copy link
Contributor

Hey,

First of all, thank you very much for your contribution!

Per-port specific configuration for load balancers is currently part of a broader discussion. This issue summarizes the situation quite well. As mentioned there, I’ll review the options for per-port configuration and draft a proposal to ensure a consistent experience. If the team agrees with the direction, we can move forward with the implementation, and I’ll revisit your PR at that point.

The failing e2e tests on forks are expected.

Best regards,
Lukas

@cfi2017
Copy link
Author

cfi2017 commented Jul 21, 2025

I'm

Hey,

First of all, thank you very much for your contribution!

Per-port specific configuration for load balancers is currently part of a broader discussion. This issue summarizes the situation quite well. As mentioned there, I’ll review the options for per-port configuration and draft a proposal to ensure a consistent experience. If the team agrees with the direction, we can move forward with the implementation, and I’ll revisit your PR at that point.

The failing e2e tests on forks are expected.

Best regards, Lukas

Hey Lukas

Thanks, and I'm happy to help with implementation. For the time being I've switched to proxy protocol which fits my use-case well (forwarding IP headers would be nice, but my Ingress supports this kind of termination).

I've thought about this some more and if I were to move forward on this I'd probably rewrite this to maintain the same annotation names as upstream, but with an added port at the end of the name, eg. load-balancer.hetzner.cloud/protocol/443: https - you'd have multiple annotations for a mapping, but this would be easier to understand and more extendable.

@lukasmetzner
Copy link
Contributor

but with an added port at the end of the name, eg. load-balancer.hetzner.cloud/protocol/443: https - you'd have multiple annotations for a mapping, but this would be easier to understand and more extendable.

This will not work unfortunately, as there is only one slash allowed in the annotation to separate key/value. Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set

@cfi2017
Copy link
Author

cfi2017 commented Jul 21, 2025

but with an added port at the end of the name, eg. load-balancer.hetzner.cloud/protocol/443: https - you'd have multiple annotations for a mapping, but this would be easier to understand and more extendable.

This will not work unfortunately, as there is only one slash allowed in the annotation to separate key/value. Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set

I think my main issue with my current approach is that it's fairly convoluted. We could use a different separation character for the port, since ultimately the actual separation character does not really matter. I think that's still a cleaner solution than encoding a map in annotations, even if the Kubernetes annotation spec specifically allows for structured data in annotations. I still think it should be human-readable.

@github-actions
Copy link
Contributor

This PR has been marked as stale because it has not had recent activity. The bot will close the PR if no further action occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants